/**
 * @project name:springssm
 */
package com.situ.ssm.util;

import com.situ.ssm.user.pojo.User;

import javax.servlet.http.HttpSession;

/**
 * @Project :springssm
 * @Author : yun&bo
 * @Date 2020/12/17 16:21
 * @Version
 */
public class ServletUtil {
    public static User getUserBySession(HttpSession session) {
        Object object = session.getAttribute(ConfigUtil.SESSION_LOGIN_USER_NAME);
        if (object != null) {
            return (User) object;
        }
        return null;
    }

    /**
     * 从session中拿到用户实例
     * @param session
     * @return
     */
    public static String getUserCodeBySession(HttpSession session){
        User user = getUserBySession(session);
        if (user!=null){
            return user.getUserCode();
        }
        return null;
    }

}
